-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SimplifyCFG] Refine metadata handling during instruction hoisting #158448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-llvm-transforms Author: William Moses (wsmoses) ChangesFull diff: https://github.com/llvm/llvm-project/pull/158448.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 5a842f9b49c1b..6d6e32d51b62e 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3387,11 +3387,13 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
// Metadata can be dependent on the condition we are hoisting above.
// Strip all UB-implying metadata on the instruction. Drop the debug loc
// to avoid making it appear as if the condition is a constant, which would
- // be misleading while debugging.
+ // be misleading while debugging. However, make sure to keep debug info
+ // for calls as inlinable function calls in a function with debug info must
+ // have a !dbg location.
// Similarly strip attributes that maybe dependent on condition we are
// hoisting above.
for (auto &I : make_early_inc_range(*ThenBB)) {
- if (!SpeculatedStoreValue || &I != SpeculatedStore) {
+ if (!SpeculatedStoreValue || &I != SpeculatedStore && !isa<CallBase>(&I)) {
I.setDebugLoc(DebugLoc::getDropped());
}
I.dropUBImplyingAttrsAndMetadata();
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test?
Yeah, though I'm a bit unsure how to set one up for this part of the pass |
@fhahn okay figured it out, can you give it a review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
llvm/test/Transforms/SimplifyCFG/no-drop-debug-loc-when-speculating-call.ll
Outdated
Show resolved
Hide resolved
…ating-call.ll Co-authored-by: Nikita Popov <[email protected]>
…lvm#158448) Co-authored-by: Nikita Popov <[email protected]> (cherry picked from commit c44e015)
…lvm#158448) Co-authored-by: Nikita Popov <[email protected]> (cherry picked from commit c44e015)
…lvm#158448) Co-authored-by: Nikita Popov <[email protected]> (cherry picked from commit c44e015)
…lvm#158448) Co-authored-by: Nikita Popov <[email protected]> (cherry picked from commit c44e015)
…lvm#158448) Co-authored-by: Nikita Popov <[email protected]> (cherry picked from commit c44e015)
No description provided.